package com.atguigu.gmall.order.client;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.order.client.impl.OrderDegradeFeignClient;
import com.atguigu.gmall.order.model.OrderInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@FeignClient(value = "service-order", path = "/api/order", fallback = OrderDegradeFeignClient.class)
public interface OrderFeignClient {

    /**
     * 当前用户-汇总订单确认所需要数据
     * TODO:当Feign接口方法提供方方法中有HttpServletRequest一定不能设置，如果设置会封装参数异常
     *
     * @return
     */
    @GetMapping("/auth/trade")
    public Result<Map> orderTadeData();


    /**
     * 根据订单ID查询订单信息
     *
     * @param orderId
     * @return
     */
    @ApiOperation("根据订单ID查询订单信息")
    @GetMapping("/inner/getOrderInfo/{orderId}")
    public OrderInfo getOrderInfo(@PathVariable("orderId") Long orderId);


    /**
     * 提供给秒杀服务调用保存秒杀订单
     *
     * @param orderInfo
     * @return
     */
    @PostMapping("/inner/seckill/submitOrder")
    public Long submitSeckillOrder(@RequestBody OrderInfo orderInfo);
}
